<?php
/**
 * Index.php
 * Niushop商城系统 - 团队十年电商经验汇集巨献!
 * =========================================================
 * Copy right 2015-2025 山西牛酷信息科技有限公司, 保留所有权利。
 * ----------------------------------------------
 * 官方网址: http://www.niushop.com.cn
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用。
 * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
 * =========================================================
 * @author : niuteam
 * @date : 2015.1.17
 * @version : v1.0.0.0
 */

namespace app\agent\controller;

use addons\Nsfx\data\service\NfxRegionAgentApply;

/**
 * 服务中心
 */
class Index extends BaseController
{
	
	public function index()
	{
        if(request()->isAjax()){
            $page_index = input('page_index', 1);
            $page_size = input('page_size', PAGESIZE);
            $search_text = input('search_text', '');
            $audit_status = input('audit_status', '');

            $condition = [];
            $condition['apply.uid'] = $this->uid;
            if($search_text != ''){
                $condition['user.user_tel|user.nick_name'] = ['like', '%'. $search_text .'%'];
            }
            if($audit_status != ''){
                $condition['audit_status'] = $audit_status;
            }
            $order = 'apply.apply_time desc';

            $region_agent_apply = new NfxRegionAgentApply();
            $res = $region_agent_apply->getApplyPageList($page_index, $page_size, $condition, $order);
            $audit_status = [
                'wait_audit' => '审核中',
                'check_pass' => '审核中',
                'check_refuse' => '审核拒绝',
                'confirm_pass' => '审核通过',
                'confirm_refuse' => '审核中',
            ];
            foreach($res['data'] as $key=>$val){
                $res['data'][$key]['address'] = $val['address_arr']['province_name'] . $val['address_arr']['city_name'] . $val['address_arr']['district_name'];
                $res['data'][$key]['audit_status_name'] = $audit_status[$val['audit_status']];
            }
            return $res;
        }else{

            return view($this->style . 'Index/index');
        }
	}
}